const userAbout = {
  namespaced: true,
  mutations: {
    // 更新用户信息
    UPDATEUSERINFO(state, userInfo) {
      state.userInfo = userInfo
      this.commit('userAbout/saveUserInfoToLocal')
    },
    // 更新token
    UPDATETOKEN(state, token) {
      state.token = token
      this.commit('userAbout/saveTokenToLocal')
    },
    // 保存用户信息到本地
    saveUserInfoToLocal(state) {
      uni.setStorageSync('userInfo', JSON.stringify(state.userInfo))
    },
    // 保存token到本地
    saveTokenToLocal(state) {
      uni.setStorageSync('token', state.token)
    }
  },
  state: {
    token: uni.getStorageSync('token') || '',
    userInfo: JSON.parse(uni.getStorageSync('userInfo') || '{}')
  },
  getters: {}
}
export default userAbout